$("#nav").load("/dev/views/common/nav.html")

if (localStorage.getItem('num')==null){
    $(document).ready(function () {
        localStorage.setItem('num', 101)
        var data = [{
            'title':'暂无历史记录',
            'id':101
        }];

        data = JSON.stringify(data)
        localStorage.setItem('data', data)
        // console.log(localStorage.getItem('data'))
    })
}
function sousuo() {
    let baseInput = document.getElementById("ID-dropdown-demo-base-input")
    if (baseInput.value!=""){
        // console.log(localStorage.getItem('jilu'))
        let num = localStorage.getItem('num')
        let data = localStorage.getItem('data')
        // console.log(data)
        num = Number(num) + 1
        var baseData = [{
            "title": baseInput.value,
            "id": num
        }]
        data = JSON.parse(data)
        if(data[0].id==101){
            data=[]
        }
        if (data[9]!=null){
            data.pop()
        }
        data = baseData.concat(data)
        for (let i=1;i<data.length;i++){
            if (data[0].title==data[i].title){
                data.splice(i,1)
            }
        }
        data = JSON.stringify(data)
        localStorage.setItem('num', num)
        localStorage.setItem('data', data)


        window.location=`/dev/views/geek-job/geek-job-city.html?baseInput=${baseInput.value}`
    }


}

let ites = document.querySelectorAll(".layui-nav-item")

let ggp = document.getElementById('ggp')
let whiteGgp = document.getElementById("white-ggp")


// function dj(num) {
//     // console.log(ites[num])
//     ites[num].style.backgroundColor = "#b7ccba"
//     whiteGgp.children[0].innerText = ites[num].children[0].innerText
//     whiteGgp.style.display = "block";
//     ggp.style.display = "none"
// }
//
// function over(num) {
//     ites[num].style.backgroundColor = "transparent"
//     whiteGgp.style.display = "none";
//     ggp.style.display = "block";
// }


layui.use(function() {
    var dropdown = layui.dropdown;
    dropdown.render({
        elem: '#ID-dropdown-demo-base-input',
        data: JSON.parse(localStorage.getItem("data")),
        click: function (obj) {
            this.elem.val(obj.title);
        },
        style: 'min-width: 661px; border-radius: 10px;'
    });
})


layui.use(function(){
    var dropdown = layui.dropdown;
    // 绑定文字
    dropdown.render({
        elem: '#position-xiala',
        id: 'xiala',
        data: [{
            title: '互联网/AI',
            id: 100,
            child: [{
                title: "",
                id: 1,
                // templet:'<div style="min-width: 661px; border-radius: 10px;height: 300px;">' +
                //     '<button type="button" style="background: none;border: white;">这是一个按钮</button>' +
                //     '</div>'
            }]
        },{
            title: '电子/电气/通信',
            id: 101,
            child: [{
                title: "",
                id: 1,
                // templet:'<div style="min-width: 661px; border-radius: 10px;height: 300px;">' +
                //     '<button type="button" style="background: none;border: white;">这是一个按钮</button>' +
                //     '</div>'
            }]
        },{
            title: '产品',
            id: 102,
            child: [{
                title: "",
                id: 1,
                // templet:'<div style="min-width: 661px; border-radius: 10px;height: 300px;">' +
                //     '<button type="button" style="background: none;border: white;">这是一个按钮</button>' +
                //     '</div>'
            }]
        }],
        click: function(obj){
            this.elem.val(obj.title);
        },
        style: 'min-width: 171px; max-height:242px; border-radius: 10px;'
    });
    dropdown.close('xiala');
});close